﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using static WPF_PathSearchUtil.MainWindow;

namespace WPF_PathSearchUtil.views
{
    /// <summary>
    /// FindForm.xaml 的交互逻辑
    /// </summary>
    public partial class FindForm : Window
    {
        public event FindFormConfirmEventHandler FindFormConfirm;
        public FindForm()
        {
            InitializeComponent();
        }

        private void FindWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape) Close();
            if (e.Key == Key.F8) Confirm.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
        }

        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            if (FindWord.Text.Length <= 0)
            {
                MessageBox.Show("请输入要检索的文件名。", "提示");
                return;
            }
            String findWord = FindWord.Text;
            FindFormConfirm(findWord);
            Close();
        }

        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}
